<?php

class Application_Model_DbTable_Robot extends Zend_Db_Table_Abstract {

    protected $_name = 'robot';
    
    public function getAllRobot(){
    	$rows = $this->fetchAll();
    	return $rows;
    }
	
	public function getAllRobotInPark($location){
        $rows = $this->fetchAll("botsLocation=".$location);
        return $rows;
	}
	
	public function getRobot($id){
		$row = $this->fetchRow("id=".$id);
		return $row;
	}
	
	public function getRobotByUserId($userId){
		$row = $this->fetchRow("userId=".$userId);
		return $row;
	}
		
	public function createRobot($userId,$gender,$name, $birthday){
		$row = $this->createRow();
		$row->userId = $userId;
		$row->gender = $gender;
		$row->name = $name;
		$row->birthday = $birthday;
		$row->save();
		return $row;
	}
	
	public function updateRobot($id,$name){
		$row = $this->getRobot($id);
		$row->name = $name;
		$row->save();
		return $row;
	}
	
	public function updateLoction($id,$location){
		$row = $this->getRobot($id);
		$row->botsLocation = $location;
		$row->save();
		return $row;
	}
}
